package cc.comac.mom.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.mom.api.QualityQarBasicStandardService;
import cc.comac.mom.bean.QualityQarBasicStandard;
import cc.comac.mom.util.ResultBean;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/QualityQarBasicStandard")
public class QualityQarBasicStandardController {

	@Autowired
	private QualityQarBasicStandardService qualityQarBasicStandardService;

	// 新增或者提交qar母本按钮
	@ApiOperation("新增或者提交qar母本按钮")
	@RequestMapping(value = "/insertQarBasicStandard", method = RequestMethod.POST)
	public ResultBean insertQarBasicStandard(@RequestBody QualityQarBasicStandard qualityQarBasicStandard) {
		ResultBean insertQarBasicStandard = qualityQarBasicStandardService
				.insertQarBasicStandard(qualityQarBasicStandard);
		return insertQarBasicStandard;
	}

	// 通过母本主键获取母本信息
	@ApiOperation("通过母本主键获取母本信息")
	@RequestMapping(value = "/selectByQarBasicStandardId", method = RequestMethod.POST)
	public ResultBean selectByQarBasicStandardId(@RequestBody QualityQarBasicStandard qualityQarBasicStandard) {
		return qualityQarBasicStandardService.selectByQarBasicStandardId(qualityQarBasicStandard);
	}

	// 通过母本主键删除对应数据信息及附属信息
	@ApiOperation("通过母本主键删除对应数据信息及附属信息")
	@RequestMapping(value = "/batchDeleteByQarBasicStandardIds", method = RequestMethod.POST)
	public ResultBean batchDeleteByQarBasicStandardIds(@RequestBody List<QualityQarBasicStandard> list) {
		return qualityQarBasicStandardService.batchDeleteByQarBasicStandardIds(list);
	}

	// 母本升版中
	@ApiOperation("母本升版中")
	@RequestMapping(value = "/qarBasicStandardUpgradeIng", method = RequestMethod.POST)
	public ResultBean qarBasicStandardUpgradeIng(@RequestBody QualityQarBasicStandard qualityQarBasicStandard) {
		qualityQarBasicStandard.getInnerData().setStatus("1");
		ResultBean qarBasicStandardUpgrade = qualityQarBasicStandardService
				.qarBasicStandardUpgrade(qualityQarBasicStandard);
		return qarBasicStandardUpgrade;
	}

	// 母本升版功能
	@ApiOperation("母本升版功能")
	@RequestMapping(value = "/qarBasicStandardUpgrade", method = RequestMethod.POST)
	public ResultBean qarBasicStandardUpgrade(@RequestBody QualityQarBasicStandard qualityQarBasicStandard) {
		ResultBean qarBasicStandardUpgrade = qualityQarBasicStandardService
				.qarBasicStandardUpgrade(qualityQarBasicStandard);
		return qarBasicStandardUpgrade;
	}

	// 取消升版功能
	@ApiOperation("取消升版功能")
	@RequestMapping(value = "/cancelQarBasicStandardUpgrade", method = RequestMethod.POST)
	public ResultBean cancelQarBasicStandardUpgrade(@RequestBody QualityQarBasicStandard qualityQarBasicStandard) {
		ResultBean cancelQarBasicStandardUpgrade = qualityQarBasicStandardService
				.cancelQarBasicStandardUpgrade(qualityQarBasicStandard);
		return cancelQarBasicStandardUpgrade;
	}

	// 分页查询qar母本对应数据
	@ApiOperation("分页查询qar母本对应数据")
	@RequestMapping(value = "/selectBySomeFields", method = RequestMethod.POST)
	public ResultBean selectBySomeFields(@RequestBody QualityQarBasicStandard qualityQarBasicStandard) {
		ResultBean selectBySomeFields = qualityQarBasicStandardService.selectBySomeFields(qualityQarBasicStandard);
		return selectBySomeFields;
	}
	
	
}
